package com.tanhua.manage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.manage.domain.AdminLog;
import com.tanhua.manage.service.IAdminLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.support.SimpleTriggerContext;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/admin/log")
public class AdminLogController {

    @Autowired(required = false)
    private IAdminLogService adminLogService;

    @GetMapping
    public ResponseEntity<Object> queryLogAll(@RequestParam(defaultValue = "1") Integer page,
                                              @RequestParam(defaultValue = "10") Integer pagesize,
                                              Long startDate,Integer queryOperModel,String qureyAdminName){
        String formatDate=null;
        if (!StringUtils.isEmpty(startDate)){
            formatDate= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startDate);
        }
        String operModel=null;
        if (!StringUtils.isEmpty(queryOperModel)){
            operModel= getOperModel(queryOperModel);
        }
        Page<AdminLog> adminLogs= adminLogService.queryAll(page,pagesize,formatDate,operModel,qureyAdminName);
        return ResponseEntity.ok(adminLogs);
    }

    public String getOperModel(Integer queryOperModel){
        switch (queryOperModel){
            case 1:
                return "查询模块";
            case 2:
                return "登陆模块";
            case 3:
                return "冻结模块";
            case 4:
                return "审核模块";
            default:
                return "";
        }
    }
}
